
$('#btnLogin').click(function(){
	getIndexPage();
});

function getIndexPage() {
	var username = $('#inputUsername');

    $.ajax({
        type: "post",
        url: "loginAction",
        dataType: "json",
        data: {
			username: inputUsername.val(),
            password: inputPassword.val()
        },
        complete: function () {
        },
        success: function (data) {
			if (data.status == 0) {
				$(location).attr('href','commonIndexPage');
			} else {
				$('#wrongpwd-modal-body').html(data.msg);
				$('#wrongpwd-modal').modal({
        			keyboard: true
    			});
			}
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
			alert(errorThrown);
        }
    });
};
//boostrap treeview 待实现
/*function getTree() {
    var data = paserJson("{{ dataString }}","{{ structString }}");
    console.log(data);
    return data;
}
$('#userTree').treeview({data: getTree()});*/


$('#btnLogin').click(function(){
	getUserListPage();
});

function getUserListPage() {
    $.ajax({
        type: "post",
        url: "loginAction",
        dataType: "json",
        data: {
			username: inputUsername.val(),
            password: inputPassword.val()
        },
        complete: function () {
        },
        success: function (data) {
			if (data.status == 0) {
				$(location).attr('href','indexPage');
			} else {
				$('#wrongpwd-modal-body').html(data.msg);
				$('#wrongpwd-modal').modal({
        			keyboard: true
    			});
			}
		},
		error: function (XMLHttpRequest, textStatus, errorThrown) {
			alert(errorThrown);
        }
    });
};